package com.xll.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.xll.entity.MedicalExamination;
import com.xll.mapper.MedicalExaminationMapper;
import com.xll.service.MedicalExaminationService;
import com.xll.utils.PageResult;
import com.xll.utils.QueryInfo;
import com.xll.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
@Slf4j
public class MedicalExaminationServiceImpl  implements MedicalExaminationService {

    @Autowired
    private  MedicalExaminationMapper medicalExaminationMapper;


    @Override
    public Result delete(Long id) {
        medicalExaminationMapper.delete(id);
        return Result.success("内科检查记录删除成功");
    }

    @Override
    public Result update(MedicalExamination medicalExamination) {
        medicalExaminationMapper.update(medicalExamination);
        return  Result.success("内科检查记录更新成功");
    }

    @Override
    public Result findPage(QueryInfo queryInfo) {
        PageHelper.startPage(queryInfo.getPageNumber(), queryInfo.getPageSize());
        Page<MedicalExamination> page = medicalExaminationMapper.findPage(queryInfo.getQueryString());
        return Result.success("内科检查记录查询成功", new PageResult(page.getTotal(), page.getResult()));
    }

    @Override
    public Result insert(MedicalExamination medicalExamination) {
        medicalExaminationMapper.insert(medicalExamination);
        return  Result.success("内科检查记录插入成功");
    }
}
